// pages/TradingAreaCenter/shopCircleList.js
const controller = require("../controllers/Controller").controller
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopGroupList: [],
    name: "",
    timer: '',
    tablist: ['全部', '正常', '待审核', '未通过'],
    currentIndex: 0,
  },
  changeTabList(e) {
    let index = e.currentTarget.dataset.index;
    this.setData({
      currentIndex: index,
    })
    this.getShopGroupList()
  },

  //获取商圈名称
  getShopCircleName(e) {
    this.setData({
      name: e.detail.value
    })
    if (this.timer) clearTimeout(this.timer)
    this.timer = setTimeout(() => {
      this.getShopGroupList()
    }, 500);
  },

  seeReason(e) {
    let index = e.currentTarget.dataset.index
    let reason = this.data.shopGroupList[index].examineDesc
    wx.showModal({
      title: "原因",
      showCancel: false,
      content: reason || ''
    })
  },
  reExamine(e){
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/TradingAreaCenter/addShopCircle?id='+id ,
    })
  },

  //获取商圈列表
  getShopGroupList() {
    let value = {}
    let examineState = ''
    value.name = this.data.name
    switch (this.data.currentIndex) {
      case 1:
        examineState = 0;
        break;
      case 2:
        examineState = 2;
        break;
      case 3:
        examineState = 1;
        break;

    }
    value.examineState=examineState
    controller.myShopGroupList(value).then(res => {
      this.setData({
        shopGroupList: res.data
      })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getShopGroupList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})